package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.yunhe.dao.BoardDao;
import cn.yunhe.dao.impl.BoardDaoImpl;
import cn.yunhe.entity.Board;

/**
 * Servlet implementation class BoardMenuServlet
 */
@WebServlet("/BoardMenuServlet")
public class BoardMenuServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public BoardMenuServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.getWriter().append("Served at: ").append(request.getContextPath());
		BoardDao  boardao=new BoardDaoImpl();
		List<Board> blist=boardao.findAllBoard();
		//System.out.println(blist.size());
		/*for (Board board : blist) {
			System.out.println("!!!"+board.getName());
		}*/
		request.setAttribute("blist",blist);
		request.getRequestDispatcher("leftMenu.jsp").forward(request, response);
	/*	System.out.println(	request.getAttribute("blist"));*/
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
